/*
		序列中删除指定数字
		https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7?tpId=107&&tqId=33379&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking
		夏思成

		2024年4月8日

		西科大15号公寓楼
*/


#include <stdio.h>
#include <stdlib.h>

int* Del_num(size_t numsSize, int* nums, int k, int* returnSize)
{
    int* ret = (int*)malloc(sizeof(int) * numsSize);
    int i = 0;
    int j = 0;
    for (i = 0; i < numsSize; i++, j++)
    {
        if (nums[i] != k)
        {
            ret[j] = nums[i];
        }
        else
        {
            j--;
        }
    }
    *returnSize = j;
    return ret;
}

int main()
{
    //序列长度
    int numsSize = 0;
    int nums[51] = { 0 };
    scanf("%d", &numsSize);

    //输入N个整数
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        scanf("%d", &nums[i]);
    }

    //要删除的数
    int k = 0;
    scanf("%d", &k);

    int returnSize = 0;
    int* ret = Del_num(numsSize, nums, k, &returnSize);

    for (i = 0; i < returnSize; i++)
    {
        printf("%d ", ret[i]);
    }
    return 0;
}